<?php
/**
 * 获取巡查记录信息 模型
 * @authors xiadx (xiadx@zpdchina.com)
 * @date    2017-03-06 11:13:33
 * @version $Id$
 */

class DataXunchajiluItemModel extends BaseModel {

	/**
     * 返回给终端的可执行sql语句的字段名称数组
     * @var [type]
     */
    public $_field_arr = ['id','parent_id','xuncha_item_code','xuncha_item_name','xuncha_item_type','xuncha_time_order','is_include','extend1','extend2'];


    public function ls($user_department='')
    {
    	$field_str = implode(',', $this->_field_arr);
		$query = DB::select($field_str)
					->from('data_xunchajilu_item')
					->where('is_include', '=', 1)
					->and_where('yiyuan_id', '=', $this->yiyuan_id)
					->and_where_open()
						->or_where('extend1', '=', $user_department)
						->or_where('extend1', '=', '通用')
						->or_where('extend1', 'IS', NULL)
                        ->or_where('extend1', '=', "")
					->and_where_close()
					->execute()
					->as_array();
		return $query;
    }

    
    public function ls_item(){
        $field_str = implode(',', $this->_field_arr);
        $query = DB::select($field_str)
            ->from('data_xunchajilu_item')
            ->where('is_include', '=', 1)
            ->and_where('yiyuan_id', '=', $this->yiyuan_id)
            ->execute()
            ->as_array();
        return $query;
    }
}
